package com.zbkj.admin.controller.brand;

import com.zbkj.common.result.CommonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import com.zbkj.service.service.CommunityBrokerageService;
import com.zbkj.common.response.CommunityBrokerageDetailResponse;

import com.zbkj.common.request.CommunityBrokerageSaveRequest;

/**
 * 小区分佣设置表 前端控制器
 */
@Slf4j
@RestController
@RequestMapping("api/admin/brand/community/brokerage")
@Api(tags = "小区分佣设置管理") //配合swagger使用

public class BrandCommunityBrokerageController {

    @Autowired
    private CommunityBrokerageService communityBrokerageService;


    /**
     * 修改小区分佣设置表
     * @param communityBrokerageRequest 修改参数
     * @author Caiyc
     * @author Caiyc
     * @since 2025-07-21
     */
    @ApiOperation(value = "修改")
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public CommonResult<String> update(@RequestBody @Validated CommunityBrokerageSaveRequest communityBrokerageRequest) {
        if (communityBrokerageService.update(communityBrokerageRequest)) {
            return CommonResult.success();
        } else {
            return CommonResult.failed();
        }
    }

    /**
     * 查询小区分佣设置表详情
     * @param agentRegionId 代理区域ID
     * @author Caiyc
     * @since 2025-07-21
     */
    @ApiOperation(value = "详情")
    @RequestMapping(value = "/info/{agentRegionId}", method = RequestMethod.GET)
    public CommonResult<CommunityBrokerageDetailResponse> getDetails(@PathVariable("agentRegionId") Integer agentRegionId) {
        return CommonResult.success(communityBrokerageService.getDetails(agentRegionId));
    }

}



